<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div{
            width:300px;
            text-align: center;
            border:1px solid #000;
        }
        #title{
            line-height: 50px;
            cursor: pointer;
            background: #abcdef;
        }
        #content{
            line-height: 250px;
            
        }
        .hide{
            display: none;
        }

    </style>
</head>
<body>
    <div id="title">HTML</div>
    <div id="content">
        HTML负责网页的结构
    </div>
    <script>
        var title = document.getElementById("title");
        var content = document.getElementById("content");
        title.onclick = function(){
            // if(content.classList.contains("hide")){
            //     content.classList.remove("hide")
            // }
            // else{
            //     content.classList.add("hide")
            // }
            content.classList.toggle("hide");
        }
    </script>
</body>
</html>